package com.jiayang.hhotel.net;

import cn.droidlover.xdroidmvp.net.XApi;

public class Api {

    //baseURL
    public static final String API_BASE_URL = "http://192.168.1.196:8080";
    private static BuildNoService buildNoService;
    private static BuildStyleService buildStyleService;
    private static UserService userService;
    private static HomeService homeService;
    private static SettingService settingService;

    public static BuildNoService getBuildNoService() {
        if (buildNoService == null) {
            synchronized (Api.class) {
                if (buildNoService == null) {
                    buildNoService = XApi.getInstance().getRetrofit(API_BASE_URL, true).create(BuildNoService.class);
                }
            }
        }
        return buildNoService;
    }

    /**
     * 建筑风格
     * @return buildStyleService
     */
    public static BuildStyleService getBuildStyleService() {
        if (buildStyleService == null) {
            synchronized (Api.class) {
                if (buildStyleService== null) {
                    buildStyleService = XApi.getInstance().getRetrofit(API_BASE_URL, true).create(BuildStyleService.class);
                }
            }
        }
        return buildStyleService;
    }

    /**
     * 用户service
     * @return userService
     */
    public static UserService getUserService() {
        if (userService == null) {
            synchronized (Api.class) {
                if (userService== null) {
                    userService = XApi.getInstance().getRetrofit(API_BASE_URL, true).create(UserService.class);
                }
            }
        }
        return userService;
    }

    /**
     * 获取首页service 单例
     * @return
     */
    public static HomeService getHomeSer(){
        if(homeService==null){
            synchronized (Api.class){
                if(homeService==null){
                    homeService=XApi.getInstance().getRetrofit(API_BASE_URL,true).create(HomeService.class);
                }
            }
        }
        return homeService;
    }

    /**
     * 获取设置service 单例
     * @return
     */
    public static SettingService getSetSer(){
        if(settingService==null){
            synchronized (Api.class){
                if(settingService==null){
                    settingService=XApi.getInstance().getRetrofit(API_BASE_URL,true).create(SettingService.class);
                }
            }
        }
        return settingService;
    }

}
